<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../pengxuan.js"></script>
<style>
.one{width:300px;height:300px;background:green;}
</style>
<script>
window.onload=function(){
	var one=getClass('one')[0];
	var startw=parseInt(getStyle(one,'width'));
	one.onclick=function(){
		animate(one,'width',500,10,function(){
			animate(one,'height',500,10)	
		})
		
	};
	
	
};
function animate(obj,attr,end,speed,callback){
	var start=parseInt(getStyle(obj,attr));
	var flag=start<end?true:false;
	obj.time=setInterval(function(){
		if(flag){
			start+=speed;
			if(start>=end){
				clearInterval(obj.time);	
				if(callback){
					callback();	
				}
			}else{	
				obj.style[attr]=start+'px';
			}
		}else{
			start-=speed;
			if(start<=end){
				clearInterval(obj.time);	
				if(callback){
					callback();	
				}
			}else{
				obj.style[attr]=start+'px';
				
			}

		}
		
	},60)	
	
};

</script>
</head>

<body>
<div class="one">

</div>
</body>
</html>
